﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using SERP.StringMappings;
using SERP.DAO;
using SERP.Controllers;
namespace SERP.Modules.Organizations{
	public partial class OrganizationsAddNew : SERP.Modules.ModuleBase
	{
		private OrganizationsController controller = new OrganizationsController();
		protected void Page_Load(object sender, EventArgs e){
			LoadLanguage();
		}
		 //Load All lable text
		private void LoadLanguage(){	
			this.lblTitle.InnerText=SERP.Constants.APP_ADDNEW_TITLE+" "+OrganizationsStringMapping.Organizations;
			this.btnSave.Text =  Constants.APP_SAVE;
			this.btnCancel.Text =  Constants.APP_CLOSE;
			this.btnBack.Text =  Constants.APP_CANCEL;
			this.btnAddNew.Text =  Constants.APP_ADDNEW;
		}     
		private bool Save(){		
			inputControl.UpdateToModel();
			return controller.AddNew();
		}
		private void GoBack(){
			RedirectToPage("OrganizationsList");
		}
		protected void OnSave(object sender, EventArgs e){
			controller.ResetObject();
			inputControl.Model=controller.OrganizationsObject;		
			if(!inputControl.ValidateScreen())
			{
				return;
			}
			if(Save()){
				lblInfo.Text=SERP.Constants.MSS_SUCCESS;
			}
			else{
				lblInfo.Text=SERP.Constants.MSS_FAILE;
			}
			MultiView1.ActiveViewIndex=1;
		}
		protected void OnAddNew(object sender, EventArgs e){
			inputControl.ClearScreen();		
			MultiView1.ActiveViewIndex=0;
		}
		protected void OnCancel(object sender, EventArgs e){
			GoBack();
		}  
	}
}
